package com.chtw.vuedemo.controller;

import com.chtw.vuedemo.bean.Photos;
import com.chtw.vuedemo.response.RespUtil;
import com.chtw.vuedemo.response.enumutil.CodeAndMsg;
import com.chtw.vuedemo.service.impl.PhotoServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author chtw
 * @date 2020-10-05 09:38
 */
@RestController
@RequestMapping("/photo")
public class PhotoController {

    @Autowired
    private PhotoServiceImpl photoService;

    @GetMapping(value = "/list/{id}")
    public RespUtil<List<Photos>> list(@PathVariable int id) {
        try {
            return new RespUtil<>(CodeAndMsg.SUCCESS, photoService.getPhotoListByCategoryId(id));
        } catch (Exception e) {
            return new RespUtil<>(CodeAndMsg.FAIL, null);
        }
    }
}
